#include "utils.h"
#include <string>

extern bool rules[];

#define genChiffre(pos) key[pos]=charsetC[rand_r(seed) % (charsetC.length()-1)]
#define genLettre(pos) key[pos]=charsetL[rand_r(seed) % (charsetL.length()-1)]

std::string rule10(std::string key, unsigned long int iter, unsigned int *seed) {
    std::string charsetC;
    std::string charsetL;
    if (rules[1]) {
        charsetC = "12345679";
        charsetL = "ACDEF";
    } else {
        charsetC = "0123456789";
        charsetL = "ABCDEF";
    }

    if ((iter % 6) == 0) {
        genLettre(0);
        genLettre(1);
        genLettre(4);
        genLettre(5);
        genChiffre(8);
        genLettre(10);
        genChiffre(14);
        genLettre(17);
        genLettre(18);
    } else {
        genChiffre(0);
        genChiffre(1);
        genChiffre(4);
        genChiffre(5);
        genLettre(8);
        genChiffre(10);
        genLettre(14);
        genChiffre(17);
        genChiffre(18);
    }
    return key;
}
